.\"	$OpenBSD: autest.1,v 1.10 2007/05/31 19:19:42 jmc Exp $
.\"
.\" Copyright (c) 2002 Jason L. Wright (jason@thought.net)
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
.\" DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: May 31 2007 $
.Dt AUTEST 1
.Os
.Sh NAME
.Nm autest
.Nd test audio encoding output
.Sh SYNOPSIS
.Nm autest
.Op Fl f Ar device
.Op Fl r Ar rate
.Op Fl t Ar tone
.Sh DESCRIPTION
The
.Nm
utility opens an
.Xr audio 4
device and iterates through all of the encodings supported by the device,
playing a tone in the proper format.
The tone should sound identical in each of the formats.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl f Ar device
Specify the audio
.Ar device
to open.
If no device is specified,
.Pa /dev/sound
is used.
.It Fl r Ar rate
Specify the audio
.Ar rate
to test.
It will request the audio subsystem to play that Hz;
however the audio device may return a different speed.
This can be useful to test different speeds, e.g. 8000, 44100, 48000.
.It Fl t Ar tone
Specify the tone to be played (default 440Hz).
.El
.Pp
.Nm
can produce tones in any of the following formats and will skip other
formats if supported by the device:
.Pp
.Bl -tag -width "ulinear_leXX" -offset indent -compact
.It Cm mu-law
8-bit mu-law companded
.It Cm A-law
8-bit A-law companded
.\" .It Cm adpcm
.\" 4 bit adaptive differential pulse code modulation
.It Cm ulinear
8-bit unsigned linear
.It Cm ulinear_le
16-bit unsigned linear little endian
.It Cm ulinear_be
16-bit unsigned linear big endian
.It Cm slinear
8-bit signed linear (twos complement)
.It Cm slinear_le
16-bit signed linear little endian (twos complement)
.It Cm slinear_be
16-bit signed linear big endian (twos complement)
.El
.Sh OUTPUT
Interpreting the output of
.Nm
is a little tricky.
The output below is from an
.Xr auich 4 :
.Bd -literal
ulinear:8...mono(s 44100 c 45167 e 2.4%)...stereo(s 44100 c 45162 e 2.4%)
mulaw:8*...mono(s 44100 c 45166 e 2.4%)...stereo(s 44100 c 45157 e 2.3%)
alaw:8*...mono[Invalid argument]...stereo[Invalid argument]
slinear:8*...mono(s 44100 c 45171 e 2.4%)...stereo(s 44100 c 45170 e 2.4%)
slinear_le:16...mono(s 44100 c 45171 e 2.4%)...stereo(s 44100 c 45170 e 2.4%)
ulinear_le:16*...mono(s 44100 c 45167 e 2.4%)...stereo(s 44100 c 45168 e 2.4%)
slinear_be:16*...mono(s 44100 c 45169 e 2.4%)...stereo(s 44100 c 45167 e 2.4%)
ulinear_be:16*...mono(s 44100 c 45167 e 2.4%)...stereo(s 44100 c 45160 e 2.3%)
.Ed
.Pp
.Nm
loops through each mode claimed to be supported by the chip (emulated or not).
For each emulated mode, an asterisk is appended to the mode name.
If the tone sounds different from all the other tones for the device,
it is likely that either the emulation is wrong, or the mode is not
set on the device correctly.
.Pp
Also, for the mono and stereo versions of each mode,
.Nm
prints the claimed sample rate,
.So s Bo rate Bc Sc ,
computed sample rate,
.So c Bo rate Bc Sc ,
and the percent error between them,
.So e Bo percent Bc Sc .
If the percent error is high (greater than 10 percent or so),
either the sample rate is not being correctly returned by
the device, or it is not being set correctly on the device.
.Pp
Interestingly, when
.Nm
requests
.Sq alaw
encoding, the device driver returns
.So Invalid argument Sc .
This indicates that the device includes
.Sq alaw
in its mode enumeration, but does not support it for playback.
This is very likely a bug in the driver.
.Sh SEE ALSO
.Xr audio 4
.Sh BUGS
There is partial support for adaptive differential pulse code modulation
(ADPCM)
but it is not enabled by default
since it does not appear to be correct.
